package com.dl7.mvp.api;

import com.dl7.mvp.music.bean.MusicAlbumList;
import com.dl7.mvp.music.bean.MusicBean;
import com.dl7.mvp.music.bean.MusicCategoryList;
import com.dl7.mvp.video.bean.VideoCategoryList;
import com.dl7.mvp.video.bean.VideoAlbumList;
import com.dl7.mvp.video.bean.RcmdVideoAlbumList;
import com.dl7.mvp.video.bean.RcmdVideoList;

import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;

import static com.dl7.mvp.api.RetrofitService.CACHE_CONTROL_NETWORK;

/**
 * Created by long on 2016/8/22.
 * API 接口
 */
public interface INewsApi {
    /**
     * 获取推荐视频列表
     * @return
     */
    @Headers(CACHE_CONTROL_NETWORK)
    @GET("api/v1/home_items")
    Observable<RcmdVideoList> getRcmdVideoList(@Query("type") int type, @Query("channel") String channel, @Query("offset") int offset, @Query("limit") int limit);

    /**
     * 获取推荐专辑列表(Banner)
     * http://api.ergedd.com/api/v1/albums/home_recommended?channel=new&offset=0&limit=16
     * @return
     */
    @Headers(CACHE_CONTROL_NETWORK)
    @GET("api/v1/albums/home_recommended")
    Observable<RcmdVideoAlbumList> getRcmdVideoAlbumListBanner(@Query("channel") String channel, @Query("offset") int offset, @Query("limit") int limit);

    /**
     * 获取所有专辑分类以及专辑列表
     * http://api.ergedd.com//api/v1/album_categories?channel=new&offset=0&limit=100&addition_album_count=20
     * @return
     */
    @Headers(CACHE_CONTROL_NETWORK)
    @GET("api/v1/album_categories")
    Observable<VideoCategoryList> getVideoCategoryList(@Query("channel") String channel, @Query("offset") int offset, @Query("limit") int limit, @Query("addition_album_count") int addition_album_count);

    /**
     * 获取专辑包含的视频列表
     * http://api.ergedd.com/api/v1/albums/175/videos?channel=new&offset=0&limit=20
     * @return
     */
    @Headers(CACHE_CONTROL_NETWORK)
    @GET("api/v1/albums/{id}/videos")
    Observable<VideoAlbumList> getAlbumDetailList(@Path("id") int id, @Query("channel") String channel, @Query("offset") int offset, @Query("limit") int limit);

    //========================music================================
    /**
     * 获取儿歌专辑列表
     *  http://api.ergedd.com/api/v1/audio_categories/2/playlists?channel=new&offset=0&limit=20
     */
    @Headers(CACHE_CONTROL_NETWORK)
    @GET("api/v1/audio_categories/{id}/playlists")
    Observable<MusicAlbumList> getMusicAlbumList(@Path("id") int id, @Query("channel") String channel, @Query("offset") int offset, @Query("limit") int limit);

    /**
     * 获取儿歌专辑推荐Banner
     *  http://api.ergedd.com/api/v1/app_configs?types=promotion_audio_banner
     */
    @Headers(CACHE_CONTROL_NETWORK)
    @GET("api/v1/app_configs?types=promotion_audio_banner")
    Observable<MusicAlbumList> getRcmdMusicAlbumListBanner();

    /**
     * 儿歌精选专辑
     *  http://api.ergedd.com/api/v1/audio_playlists/excellent?channel=original
     */
    @Headers(CACHE_CONTROL_NETWORK)
    @GET("api/v1/audio_playlists/excellent?channel=original")
    Observable<MusicAlbumList> getRcmdMusicAlbumList();

    /**
     * 儿歌分类列表(通过id可查询其他分类下的专辑列表)
     *  http://api.ergedd.com/api/v1/audio_categories?channel=original
     */
    @Headers(CACHE_CONTROL_NETWORK)
    @GET("api/v1/audio_categories?channel=original")
    Observable<MusicCategoryList> getRcmdMusicCategoryList();

    /**
     * 获取专辑详情
     * apid=245&offset=0&limit=20&os=3&code=20468&uuid=6f8d6e0c-a0fa-450b-b0f7-151de92430cc&channel=taobao
     * @return
     */
    @FormUrlEncoded
    @POST("getAudioByPlaylistId")
    Observable<MusicBean> getMusicList(@Field("apid") int ip, @Field("offset") int offset, @Field("limit") int limit);
}
